//
//  MyBidJobDetailTabHistory.swift
//  ezyform
//
//  Created by MoennigQ on 12/12/18.
//  Copyright © 2018 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import SnapKit
import RxSwift
import RxCocoa
import RxRelay
class ServiceDetailTabHistory: View {
    private lazy var disposeBag = DisposeBag()
    var tableView = TableView()
    override func setUpView() {
        self.backgroundColor = UIColor(hexStr: Constant.SystemBackColor)
        //1.Job Detail
        let historyTitle = ContentLabel(R.font.interRegular(size: 12), hexStr: "#292D3299")
        historyTitle.text = "HISTORY"
        self.addSubview(historyTitle)
        historyTitle.snp.makeConstraints { (make) in
            make.top.equalTo(20)
            make.left.equalTo(24)
            make.height.width.greaterThanOrEqualTo(0)
        }
        
        //1. tabview history
        self.tableView.backgroundColor = .clear
        self.addSubview(self.tableView)
        tableView.snp.makeConstraints { (make) in
            make.top.equalTo(historyTitle.snp.bottom).offset(9)
            make.left.right.bottom.equalToSuperview()
        }
        tableView.register(ServcieDetailHistoryTableViewCell.self, forCellReuseIdentifier: ServcieDetailHistoryTableViewCell.reuseCellIdentifier)
        tableView.estimatedRowHeight = 50
        tableView.rowHeight = UITableView.automaticDimension
        if #available(iOS 15.0, *) {//iOS 15会默认有22点的高度,需要代码设置为0
            tableView.sectionHeaderTopPadding = 0
        }
        //绑定数据源，自动刷新数据
        ServiceDetailModelHelper.shared.historyList.bind(to: tableView.rx.items(cellIdentifier: ServcieDetailHistoryTableViewCell.reuseCellIdentifier, cellType: ServcieDetailHistoryTableViewCell.self)){ row, model, cell in
            cell.setData(model, firstRowFlag: (row == 0 ? true : false) )
        }.disposed(by: self.disposeBag)
    }
}
